﻿using OrderStateMachineWebApi_V2.Models;
using OrderStateMachineWebApi_V2.Services;

namespace OrderStateMachineWebApi_V2.ServicesImpl
{
    public class ShippedState : IOrderState
    {
        private readonly Order _order;
        public string StateName => "Shipped";

        public ShippedState(Order order)
        {
            _order = order;
        }

        public bool ProcessAction(OrderAction action)
        {
            switch (action)
            {
                case OrderAction.Deliver:
                    _order.State = new DeliveredState(_order);
                    _order.RecordTransition(StateName, action);
                    return true;
                case OrderAction.Return:
                    _order.State = new ReturnedState(_order);
                    _order.RecordTransition(StateName, action);
                    return true;
                default:
                    return false;
            }
        }
    }
}
